<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>str_replace 的忽略大小写版本</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.str-ireplace" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_ireplace</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">str_ireplace</span> &mdash; <span class="dc-title"><span class="function"><a href="str_replace.html" class="function">str_replace()</a></span> 的忽略大小写版本</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.str-ireplace-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_ireplace</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$search</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$replace</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$subject</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$count</code></span>
  ] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
      该函数返回一个字符串或者数组。该字符串或数组是将 <code class="parameter">subject</code> 中全部的 <code class="parameter">search</code> 都被 <code class="parameter">replace</code> 替换（忽略大小写）之后的结果。如果没有一些特殊的替换规则，你应该使用该函数替换带有 <em>i</em> 修正符的 <span class="function"><a href="preg_replace.html" class="function">preg_replace()</a></span> 函数。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-ireplace-parameters">
  <h3 class="title">参数</h3>
  
  <p class="para">
   如果 <code class="parameter">search</code> 和 <code class="parameter">replace</code> 为数组，那么 <span class="function"><a href="str_replace.html" class="function">str_replace()</a></span> 将对 <code class="parameter">subject</code> 做二者的映射替换。如果 <code class="parameter">replace</code> 的值的个数少于 <code class="parameter">search</code> 的个数，多余的替换将使用空字符串来进行。如果 <code class="parameter">search</code> 是一个数组而 <code class="parameter">replace</code> 是一个字符串，那么 <code class="parameter">search</code> 中每个元素的替换将始终使用这个字符串。
  </p>
  <p class="para">
   如果 <code class="parameter">search</code> 或 <code class="parameter">replace</code> 是数组，他们的元素将从头到尾一个个处理。
  </p>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">search</code></dt>

     <dd>

       <p class="para">
        要搜索的值，就像是 <em class="emphasis">needle</em>。可以使用 array 来提供多个 needle。
       </p>
     </dd>

    
    
     <dt>
<code class="parameter">replace</code></dt>

     <dd>

      <p class="para">
       The replacement value that replaces found <code class="parameter">search</code>
       values. An array may be used to designate multiple replacements.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">subject</code></dt>

     <dd>

      <p class="para">
       要被搜索和替换的字符串或数组，就像是
      <em class="emphasis">haystack</em>。
      </p>
      <p class="para">
       如果 <code class="parameter">subject</code> 是一个数组，替换操作将遍历整个 <code class="parameter">subject</code>，并且也将返回一个数组。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">count</code></dt>

     <dd>

      <p class="para">
      如果设定了，将会设置执行替换的次数。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-ireplace-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回替换后的字符串或者数组。
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-function.str-ireplace-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5953">
    <p><strong>Example #1 <span class="function"><strong>str_ireplace()</strong></span> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$bodytag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">str_ireplace</span><span style="color: #007700">(</span><span style="color: #DD0000">"%body%"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"black"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&lt;body&nbsp;text=%BODY%&gt;"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$bodytag</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;&lt;body&nbsp;text=black&gt;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.str-ireplace-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数可安全用于二进制对象。</span></p></blockquote>
  <div class="caution"><strong class="caution">Caution</strong>
   <h1 class="title">Replacement order gotcha</h1>
   <p class="para">
    Because <span class="function"><strong>str_ireplace()</strong></span> replaces left to right, it might
    replace a previously inserted value when doing multiple replacements.
    Example #2 in the <span class="function"><a href="str_replace.html" class="function">str_replace()</a></span> documentation
    demonstrates how this may affect you in practice.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-ireplace-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="str_replace.html" class="function" rel="rdfs-seeAlso">str_replace()</a> - 子字符串替换</span></li>
    <li class="member"><span class="function"><a href="preg_replace.html" class="function" rel="rdfs-seeAlso">preg_replace()</a> - 执行一个正则表达式的搜索和替换</span></li>
    <li class="member"><span class="function"><a href="strtr.html" class="function" rel="rdfs-seeAlso">strtr()</a> - 转换指定字符</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>